#!/usr/bin/env sh

DISPLAY1="$(bspc query -M --names | awk -F: '{print $1}' | grep 'eDP1\|VGA-0')"
[[ ! -z "$DISPLAY1" ]] && bspc monitor "$DISPLAY1" -d 1 2 3 4 5 6 7 8 9 10 11 12 && bspc config -m "$DISPLAY1" top_padding 18

[[ -z `pgrep enforce` ]] && ~/.bin/enforce "$DISPLAY1" '^1' &

bspc config border_width 1
bspc config window_gap 3

bspc config split_ratio 0.5
bspc config borderless_monocle false
bspc config single_monocle true
bspc config gapless_monocle false
bspc config focus_follows_pointer true
bspc config focused_border_color "#585858"
bspc config normal_border_color "#12181d"
bspc config active_border_color "#585858"
bspc config presel_feedback_color "#9e9e9e"
bspc config click_to_focus any
bspc config honor_size_hints false
bspc config ignore_ewmh_focus true

bspc config external_rules_command "$XDG_CONFIG_HOME/bspwm/rules"

# Workspaces
bspc rule -a 'Firefox:Navigator' follow=on desktop=^1
bspc rule -a 'Firefox Developer Edition:Navigator' follow=on desktop=^1
bspc rule -a Qutebrowser follow=on desktop=^1
bspc rule -a Iceweasel follow=on desktop=^1
bspc rule -a TelegramDesktop follow=on desktop=^2 state=tiled
bspc rule -a URxvt:chat follow=on desktop=^2 state=tiled
bspc rule -a URxvt:URxvtQuake sticky=on state=floating
bspc rule -a Thunderbird follow=on desktop=^3
bspc rule -a Icedove follow=on desktop=^3
bspc rule -a Doublecmd follow=on desktop=^4
bspc rule -a URxvt:ranger follow=on desktop=^4 state=tiled
bspc rule -a JDownloader follow=off  desktop=^5
bspc rule -a Lxappearance follow=on desktop=^6 state=floating
bspc rule -a Anydesk follow=on desktop=^6 state=tiled
bspc rule -a Remmina follow=on desktop=^6 state=tiled
bspc rule -a qt5ct follow=on desktop=^6 state=floating
bspc rule -a mpv follow=on desktop=^7 state=tiled
bspc rule -a obs follow=on desktop=^7 state=tiled
bspc rule -a cantata follow=on desktop=^7 state=tiled
bspc rule -a Easytag follow=on desktop=^7 state=tiled
bspc rule -a *:libreoffice follow=off desktop=^8
bspc rule -a Soffice follow=off desktop=^8
bspc rule -a Zathura follow=on desktop=^8 state=tiled
bspc rule -a Emacs follow=on desktop=^9
bspc rule -a Wine follow=off desktop=^12 state=tiled

# Floating apps
bspc rule -a sxiv follow=off state=floating
bspc rule -a URxvt:terminal follow=off state=floating
bspc rule -a 'Firefox:firefox' follow=off state=floating manage=off
bspc rule -a 'Firefox:Browser' follow=off state=floating manage=off
bspc rule -a 'Firefox Developer Edition:firefox-developer-edition' follow=off state=floating manage=off
bspc rule -a 'Firefox Developer Edition:Browser' follow=off state=floating manage=off

# Xresources
xrdb ~/.Xresources &
# Wallpaper
[[ -e $HOME/.fehbg ]] && $HOME/.fehbg &
# i3lock Fancy
[[ -z `pgrep xss-lock` ]] && xss-lock -- i3lock-fancy -p &
# clipboard
[[ -z `pgrep clipboard` ]] && ~/.bin/clipboard &
# panel
[[ -z `pgrep panel` ]] && ~/.bin/panel &
# udiskie
[[ -z `pgrep udiskie` ]] && udiskie &
# sxhkd
[[ -z `pgrep sxhkd` ]] && sxhkd &
